// Copyright (C) Kumo inc. and its affiliates.
// Author: Jeff.li lijippy@163.com
// All rights reserved.
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published
// by the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program.  If not, see <https://www.gnu.org/licenses/>.
//
#include <pollux/functions/prestosql/aggregates/register_aggregate_functions.h>
#include <pollux/functions/prestosql/aggregates/approx_distinct_aggregates.h>
#include <pollux/functions/prestosql/aggregates/approx_most_frequent_aggregate.h>
#include <pollux/functions/prestosql/aggregates/approx_percentile_aggregate.h>
#include <pollux/functions/prestosql/aggregates/arbitrary_aggregate.h>
#include <pollux/functions/prestosql/aggregates/array_agg_aggregate.h>
#include <pollux/functions/prestosql/aggregates/average_aggregate.h>
#include <pollux/functions/prestosql/aggregates/bitwise_aggregates.h>
#include <pollux/functions/prestosql/aggregates/bitwise_xor_aggregate.h>
#include <pollux/functions/prestosql/aggregates/bool_aggregates.h>
#include <pollux/functions/prestosql/aggregates/central_moments_aggregates.h>
#include <pollux/functions/prestosql/aggregates/checksum_aggregate.h>
#include <pollux/functions/prestosql/aggregates/classification_aggregation.h>
#include <pollux/functions/prestosql/aggregates/count_aggregate.h>
#include <pollux/functions/prestosql/aggregates/count_if_aggregate.h>
#include <pollux/functions/prestosql/aggregates/covariance_aggregates.h>
#include <pollux/functions/prestosql/aggregates/entropy_aggregates.h>
#include <pollux/functions/prestosql/aggregates/geometric_mean_aggregate.h>
#include <pollux/functions/prestosql/aggregates/histogram_aggregate.h>
#include <pollux/functions/prestosql/aggregates/map_agg_aggregate.h>
#include <pollux/functions/prestosql/aggregates/map_union_aggregate.h>
#include <pollux/functions/prestosql/aggregates/map_union_sum_aggregate.h>
#include <pollux/functions/prestosql/aggregates/max_by_aggregate.h>
#include <pollux/functions/prestosql/aggregates/max_size_for_stats_aggregate.h>
#include <pollux/functions/prestosql/aggregates/min_by_aggregate.h>
#include <pollux/functions/prestosql/aggregates/min_max_aggregates.h>
#include <pollux/functions/prestosql/aggregates/multi_map_aggAggregate.h>
#include <pollux/functions/prestosql/aggregates/reduce_agg.h>
#include <pollux/functions/prestosql/aggregates/set_aggregates.h>
#include <pollux/functions/prestosql/aggregates/sum_aggregate.h>
#include <pollux/functions/prestosql/aggregates/sum_data_size_for_stats_aggregate.h>
#include <pollux/functions/prestosql/aggregates/variance_aggregates.h>
#include <pollux/functions/prestosql/types/json_registration.h>

namespace kumo::pollux::aggregate::prestosql {
    void registerAllAggregateFunctions(
        const std::string &prefix,
        bool withCompanionFunctions,
        bool onlyPrestoSignatures,
        bool overwrite) {
        registerJsonType();
        registerApproxDistinctAggregates(prefix, withCompanionFunctions, overwrite);
        registerApproxMostFrequentAggregate(
            prefix, withCompanionFunctions, overwrite);
        registerApproxPercentileAggregate(prefix, withCompanionFunctions, overwrite);
        registerArbitraryAggregate(prefix, withCompanionFunctions, overwrite);
        registerArrayAggAggregate(prefix, withCompanionFunctions, overwrite);
        registerAverageAggregate(prefix, withCompanionFunctions, overwrite);
        registerBitwiseAggregates(
            prefix, withCompanionFunctions, onlyPrestoSignatures, overwrite);
        registerBitwiseXorAggregate(
            prefix, withCompanionFunctions, onlyPrestoSignatures, overwrite);
        registerBoolAggregates(prefix, withCompanionFunctions, overwrite);
        registerCentralMomentsAggregates(prefix, withCompanionFunctions, overwrite);
        registerChecksumAggregate(prefix, withCompanionFunctions, overwrite);
        registerClassificationFunctions(prefix, withCompanionFunctions, overwrite);
        registerCountAggregate(prefix, withCompanionFunctions, overwrite);
        registerCountIfAggregate(prefix, withCompanionFunctions, overwrite);
        registerCovarianceAggregates(prefix, withCompanionFunctions, overwrite);
        registerEntropyAggregate(prefix, withCompanionFunctions, overwrite);
        registerGeometricMeanAggregate(prefix, withCompanionFunctions, overwrite);
        registerHistogramAggregate(prefix, withCompanionFunctions, overwrite);
        registerMapAggAggregate(prefix, withCompanionFunctions, overwrite);
        registerMapUnionAggregate(prefix, withCompanionFunctions, overwrite);
        registerMapUnionSumAggregate(prefix, withCompanionFunctions, overwrite);
        registerMaxDataSizeForStatsAggregate(
            prefix, withCompanionFunctions, overwrite);
        registerMultiMapAggAggregate(prefix, withCompanionFunctions, overwrite);
        registerSumDataSizeForStatsAggregate(
            prefix, withCompanionFunctions, overwrite);
        registerMinMaxAggregates(prefix, withCompanionFunctions, overwrite);
        registerMaxByAggregates(prefix, withCompanionFunctions, overwrite);
        registerMinByAggregates(prefix, withCompanionFunctions, overwrite);
        registerReduceAgg(prefix, withCompanionFunctions, overwrite);
        registerSetAggAggregate(prefix, withCompanionFunctions, overwrite);
        registerSetUnionAggregate(prefix, withCompanionFunctions, overwrite);
        registerSumAggregate(prefix, withCompanionFunctions, overwrite);
        registerVarianceAggregates(prefix, withCompanionFunctions, overwrite);
    }

    void registerInternalAggregateFunctions(const std::string &prefix) {
        bool withCompanionFunctions = false;
        bool overwrite = false;
        registerCountDistinctAggregate(prefix, withCompanionFunctions, overwrite);
        registerInternalArrayAggAggregate(prefix, withCompanionFunctions, overwrite);
    }
} // namespace kumo::pollux::aggregate::prestosql
